<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,height=device-height,viewport-fit=cover,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>还卡超人</title>
	<style>
		html,
		body {
			width: 100%;
			height: 100%;
			margin: 0;
			background: transparent;
		}
		#img {
			display: block;
			width: 100%;
			border: none;
		}
	</style>
</head>
<body>
	<img id="img" src="">
	<script>
		var $img = document.querySelector('#img');
		var isMove = false;
		var to, to2;
		$img.setAttribute('src', (new RegExp('\\?(?:.+(?:&|=))?imgsrc=([^&#]*)(?:&|#|$)').exec(location.href) || [])[1] || '');
		var handler = function () {
			clearTimeout(to);
			if (isMove) {
				isMove = false;
				$img.removeEventListener('touchend', handler);
				$img.addEventListener('touchend', scale);
				return;
			}
			$img.style.width = 'auto';
			$img.removeEventListener('touchend', handler);
			$img.addEventListener('touchend', scale2);
		};
		var handler2 = function () {
			clearTimeout(to2);
			if (isMove) {
				isMove = false;
				$img.removeEventListener('touchend', handler2);
				$img.addEventListener('touchend', scale2);
				return;
			}
			$img.style.width = '100%';
			$img.removeEventListener('touchend', handler2);
			$img.addEventListener('touchend', scale);
		};
		var scale = function () {
			if (isMove) {
				isMove = false;
				return;
			}
			$img.removeEventListener('touchend', scale);
			$img.addEventListener('touchend', handler);
			to = setTimeout(function () {
				$img.removeEventListener('touchend', handler);
				$img.addEventListener('touchend', scale);
			}, 500);
		};
		var scale2 = function () {
			if (isMove) {
				isMove = false;
				return;
			}
			$img.removeEventListener('touchend', scale2);
			$img.addEventListener('touchend', handler2);
			to2 = setTimeout(function () {
				$img.removeEventListener('touchend', handler2);
				$img.addEventListener('touchend', scale2);
			}, 500);
		};
		var moving = function () {
			isMove = true;
		};
		$img.addEventListener('touchend', scale);
		$img.addEventListener('touchmove', moving);
	</script>
</body>
</html>
